<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MQTT C Client Libraries Internals: utf-8.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="pahologo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MQTT C Client Libraries Internals
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">utf-8.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Functions for checking that strings contain UTF-8 characters only.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;utf-8.h&quot;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &quot;StackTrace.h&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for utf-8.c:</div>
<div class="dyncontent">
<div class="center"><img src="utf-8_8c__incl.png" border="0" usemap="#utf-8_8c" alt=""/></div>
<map name="utf-8_8c" id="utf-8_8c">
<area shape="rect" title="Functions for checking that strings contain UTF&#45;8 characters only." alt="" coords="51,5,110,32"/>
<area shape="rect" title=" " alt="" coords="5,80,68,107"/>
<area shape="rect" title=" " alt="" coords="93,80,157,107"/>
</map>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a25f003de16c08a4888b69f619d70f427"><td class="memItemLeft" align="right" valign="top"><a id="a25f003de16c08a4888b69f619d70f427"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a25f003de16c08a4888b69f619d70f427">ARRAY_SIZE</a>(a)&#160;&#160;&#160;(sizeof(a) / sizeof(a[0]))</td></tr>
<tr class="memdesc:a25f003de16c08a4888b69f619d70f427"><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to determine the number of elements in a single-dimension array. <br /></td></tr>
<tr class="separator:a25f003de16c08a4888b69f619d70f427"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a9727caa7417e6bed8cfad4121a22628d"><td class="memItemLeft" align="right" valign="top">static const char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d">UTF8_char_validate</a> (int <a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a>, const char *data)</td></tr>
<tr class="memdesc:a9727caa7417e6bed8cfad4121a22628d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a single UTF-8 character.  <a href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d">More...</a><br /></td></tr>
<tr class="separator:a9727caa7417e6bed8cfad4121a22628d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb">UTF8_validate</a> (int <a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a>, const char *data)</td></tr>
<tr class="memdesc:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a length-delimited string has only UTF-8 characters.  <a href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb">More...</a><br /></td></tr>
<tr class="separator:ad2012627fca4b4bdd9f67bde49b0d1cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4f3cf77538d867bb5b421bcb687dccdf"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#a4f3cf77538d867bb5b421bcb687dccdf">UTF8_validateString</a> (const char *string)</td></tr>
<tr class="memdesc:a4f3cf77538d867bb5b421bcb687dccdf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Validate a null-terminated string has only UTF-8 characters.  <a href="utf-8_8c.html#a4f3cf77538d867bb5b421bcb687dccdf">More...</a><br /></td></tr>
<tr class="separator:a4f3cf77538d867bb5b421bcb687dccdf"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ab7e6b7547aa4cd0fd122f222d1a9ba65"><td class="memItemLeft" >struct {</td></tr>
<tr class="memitem:ade16e8412f48ecd0f0fa937e1c19bed0"><td class="memItemLeft" >
&#160;&#160;&#160;int&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#afed088663f8704004425cdae2120b9b3">len</a></td></tr>
<tr class="memdesc:ade16e8412f48ecd0f0fa937e1c19bed0"><td class="mdescLeft">&#160;</td><td class="mdescRight">number of elements in the following array (1 to 4) <br /></td></tr>
<tr class="separator:ade16e8412f48ecd0f0fa937e1c19bed0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3528e5d2da18d6603b8e73764672b5fe"><td class="memItemLeft" >
&#160;&#160;&#160;struct {</td></tr>
<tr class="memitem:a1d888ec4cebcf07129279751add95b82"><td class="memItemLeft" >
&#160;&#160;&#160;&#160;&#160;&#160;char&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#a17ae1b83727db4230c8df98b4ee953fc">lower</a></td></tr>
<tr class="memdesc:a1d888ec4cebcf07129279751add95b82"><td class="mdescLeft">&#160;</td><td class="mdescRight">lower limit of valid range <br /></td></tr>
<tr class="separator:a1d888ec4cebcf07129279751add95b82"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af41926593d287eb0f125fd1de4dfc695"><td class="memItemLeft" >
&#160;&#160;&#160;&#160;&#160;&#160;char&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#a716463de5d02ad40678f2376abcdd90a">upper</a></td></tr>
<tr class="memdesc:af41926593d287eb0f125fd1de4dfc695"><td class="mdescLeft">&#160;</td><td class="mdescRight">upper limit of valid range <br /></td></tr>
<tr class="separator:af41926593d287eb0f125fd1de4dfc695"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3528e5d2da18d6603b8e73764672b5fe"><td class="memItemLeft" valign="top">&#160;&#160;&#160;}&#160;&#160;&#160;<a class="el" href="utf-8_8c.html#acce1763ab1d2658c7e6593c128565303">bytes</a> [4]</td></tr>
<tr class="memdesc:a3528e5d2da18d6603b8e73764672b5fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">up to 4 bytes can be used per character <br /></td></tr>
<tr class="separator:a3528e5d2da18d6603b8e73764672b5fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab7e6b7547aa4cd0fd122f222d1a9ba65"><td class="memItemLeft" valign="top">}&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="utf-8_8c.html#ab7e6b7547aa4cd0fd122f222d1a9ba65">valid_ranges</a> []</td></tr>
<tr class="memdesc:ab7e6b7547aa4cd0fd122f222d1a9ba65"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure to hold the valid ranges of UTF-8 characters, for each byte up to 4.  <a href="utf-8_8c.html#ab7e6b7547aa4cd0fd122f222d1a9ba65">More...</a><br /></td></tr>
<tr class="separator:ab7e6b7547aa4cd0fd122f222d1a9ba65"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Functions for checking that strings contain UTF-8 characters only. </p>
<p>See page 104 of the Unicode Standard 5.0 for the list of well formed UTF-8 byte sequences. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a9727caa7417e6bed8cfad4121a22628d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9727caa7417e6bed8cfad4121a22628d">&#9670;&nbsp;</a></span>UTF8_char_validate()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static const char * UTF8_char_validate </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Validate a single UTF-8 character. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">len</td><td>the length of the string in "data" </td></tr>
    <tr><td class="paramname">data</td><td>the bytes to check for a valid UTF-8 char </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the start of the next UTF-8 character in "data" </dd></dl>

</div>
</div>
<a id="ad2012627fca4b4bdd9f67bde49b0d1cb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad2012627fca4b4bdd9f67bde49b0d1cb">&#9670;&nbsp;</a></span>UTF8_validate()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int UTF8_validate </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Validate a length-delimited string has only UTF-8 characters. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">len</td><td>the length of the string in "data" </td></tr>
    <tr><td class="paramname">data</td><td>the bytes to check for valid UTF-8 characters </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 (true) if the string has only UTF-8 characters, 0 (false) otherwise </dd></dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph.png" border="0" usemap="#utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph" alt=""/></div>
<map name="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph" id="utf-8_8c_ad2012627fca4b4bdd9f67bde49b0d1cb_cgraph">
<area shape="rect" title="Validate a length&#45;delimited string has only UTF&#45;8 characters." alt="" coords="5,5,112,32"/>
<area shape="rect" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d" title="Validate a single UTF&#45;8 character." alt="" coords="160,5,299,32"/>
</map>
</div>

</div>
</div>
<a id="a4f3cf77538d867bb5b421bcb687dccdf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4f3cf77538d867bb5b421bcb687dccdf">&#9670;&nbsp;</a></span>UTF8_validateString()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int UTF8_validateString </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>string</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Validate a null-terminated string has only UTF-8 characters. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">string</td><td>the string to check for valid UTF-8 characters </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 (true) if the string has only UTF-8 characters, 0 (false) otherwise </dd></dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph.png" border="0" usemap="#utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph" alt=""/></div>
<map name="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph" id="utf-8_8c_a4f3cf77538d867bb5b421bcb687dccdf_cgraph">
<area shape="rect" title="Validate a null&#45;terminated string has only UTF&#45;8 characters." alt="" coords="5,5,147,32"/>
<area shape="rect" href="utf-8_8c.html#ad2012627fca4b4bdd9f67bde49b0d1cb" title="Validate a length&#45;delimited string has only UTF&#45;8 characters." alt="" coords="195,5,301,32"/>
<area shape="rect" href="utf-8_8c.html#a9727caa7417e6bed8cfad4121a22628d" title="Validate a single UTF&#45;8 character." alt="" coords="349,5,488,32"/>
</map>
</div>

</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="ab7e6b7547aa4cd0fd122f222d1a9ba65"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab7e6b7547aa4cd0fd122f222d1a9ba65">&#9670;&nbsp;</a></span>valid_ranges</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct { ... }  valid_ranges[]</td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">=</div>
<div class="line">{</div>
<div class="line">                {1, { {00, 0x7F} } },</div>
<div class="line">                {2, { {0xC2, 0xDF}, {0x80, 0xBF} } },</div>
<div class="line">                {3, { {0xE0, 0xE0}, {0xA0, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">                {3, { {0xE1, 0xEC}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">                {3, { {0xED, 0xED}, {0x80, 0x9F}, {0x80, 0xBF} } },</div>
<div class="line">                {3, { {0xEE, 0xEF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">                {4, { {0xF0, 0xF0}, {0x90, 0xBF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">                {4, { {0xF1, 0xF3}, {0x80, 0xBF}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">                {4, { {0xF4, 0xF4}, {0x80, 0x8F}, {0x80, 0xBF}, {0x80, 0xBF} } },</div>
<div class="line">}</div>
</div><!-- fragment -->
<p>Structure to hold the valid ranges of UTF-8 characters, for each byte up to 4. </p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Mon May 24 2021 18:05:54 for MQTT C Client Libraries Internals by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
